///////////////////////////////////////////////////////////////////
//	File Name	:	"CBase.h"
//
//	Author Name	:	David Brown
//
//	Purpose		:	To contain all related data and functionality
//					for our game objects.
///////////////////////////////////////////////////////////////////
#include "CBase.h"
#include "CGame.h"
#include "SGD_Math.h"
#include "SGD Wrappers\CSGD_TextureManager.h"	// included where it is used

CBase::CBase(void)
{
	m_uiRefCount = 1; // start with a ref to yourself!

	//m_nPosX = 0;
	SetPosX(0);
	SetPosY(0);
	SetVelX(0);
	SetVelY(0);
	SetImageID(-1);
	SetScale(1.0f);
	SetDebugDisplay(false);
}

CBase::~CBase(void)
{
}

void CBase::Update(float fElapsedTime)
{
	//	pos += vel			<-- frame based
	//	pos += vel * dt		<-- time based
	float prevPosX = GetPosX();
	float prevPosY = GetPosY();
	float prevVelX = GetVelX();
	float prevVelY = GetVelY();
	SetPosX( GetPosX() + GetVelX() * fElapsedTime );
	SetPosY( GetPosY() + GetVelY() * fElapsedTime );
	float newPosX = GetPosX();
	float newPosY = GetPosY();
	float velx = GetVelX();
	float vely = GetVelY();
}

void CBase::Render(void)
{
}

RECT CBase::GetRect()
{
	RECT rRect = {(LONG)GetPosX(),(LONG)GetPosY(),(LONG)(GetPosX()+GetWidth()),(LONG)(GetPosY()+GetHeight())};
	return rRect;
}

bool CBase::CheckCollision( IBaseInterface * pBase )
{
	RECT ColRect;
	bool toReturn = IntersectRect(&ColRect, &GetRect(), &pBase->GetRect() );
	return toReturn;
}


